package leecode

func checkPerfectNumber(num int) bool {
	if num == 1 {
		return false
	}
	nums := numbers(num)
	sum := 1
	for _, value := range nums {
		sum += value
	}
	return sum == num
}

// 求一个数所有的正因子
func numbers(num int) []int {
	var result []int
	for i := 2; i*i < num; i++ {
		if num%i == 0 {
			result = append(result, i)
			result = append(result, num/i)
		}
	}
	return result
}
